<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>按配送企业查看医疗机构</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>按配送企业查看医疗机构</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
           <li class="active"><a href="#">目录管理</a></li>
            <li class="active"><a href="#">配送关系管理</a></li>
            <li class="active"><a href="#">配送关系查看</a></li>
        </ol>
    </section>
		<section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">  
                <div class="form-group form-group-xs">
			            <label>医疗机构编码：</label>
			            <input class="form-control" type="text" id="hospCode" name="hospCode" placeholder="医疗机构编码"  />
			        </div>              
				    <div class="form-group form-group-xs">
			            <label>医疗机构名称：</label>
			            <input class="form-control" type="text" id="hospName" name="hospName" placeholder="医疗机构名称"  />
			        </div>
			        <div class="form-group form-group-xs">
			            <label>状态：</label>
			            <select  class="form-control"  id="status" name="status">
			            	<option value="">请选择</option>
			            	<option value="1">已确认</option>
			            	<option value="0">未确认</option>
			            </select>
			        </div>
	                <button type="button" onclick="search();" class="btn btn-success btn-sm">查&nbsp;询</button>
	            </div>			      
			</div>
		</div>
<div style="margin-top: 5px;"></div>
	<table class="jqgrid" id="gridList"></table>
<div style="margin-top: 10px;"></div>
<div id="prowed2"></div>


<div class=" box box-warning bottongroup" id="bottongroup">
			<label onclick="removeDel();" class="btn btn-default btn-sm">解除配送关系</label>
			<label  onclick="window.history.go(-1)"   class="btn btn-default btn-sm" >返 回</label>
		</div>
		</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
function removeDel() {
   	//获取选中的ID及对应的名字（参数:jqgridId,名字列名，状态列名，当前操作即列表中显示的值），返回infos[0]是ID串，infos[1]是名字串
  var infos = batchSwitchStatus("gridList","hospName","status","解除配送关系","医疗机构");
  if ( !(infos instanceof Array)){
   		return;
  }
  $.HN.message.confirm("确定为配送范围   在的   解除以下配送企业？<br/>"+infos[1].replace(/\,/g,"<br/>"), '', '').on(function (e) {
      if (e) {
      	$.ajax({
              url:"${ctx}/baseGoods/removeDel.html",//action地址
              data: {param:infos[0],status:"3"},//传值
              type: "post",//执行方式get or post 默认以post方式执行
              dataType:"json",
              success: function (result) {//执行成功后 提示
                  if (result.success){
                  	top.$.HN.message.alert("成功解除"+infos[0].split(",").length+"个配送关系！","", "success");
                  	search($("#gridList").getGridParam("page"));
                 } else {
              	   top.$.HN.message.alert("操作失败！！","", "error");
                 } 
              }
          });
      }
  });
}

$(document).ready(function (){
	$('.form-inline :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(1).focus();


	jQuery("#gridList").jqGrid({
		url: "${ctx}/baseGoods/getHospJspList.html?delCompCode=${compCode}",
	    mtype: "POST",
		datatype: "json",
		autowidth: true,
		shrinkToFit: true,
		height: 250,
	   	colNames:['id','医疗机构编码','医疗机构名称','组织机构代码','联系人','联系电话','状态'],
	   	colModel:[
			{name:'delRelId',index:'goodsCode',key:true,hidden:true,width:100,align:"center", sortable:false},
			{name:'hospCode',index:'goodsCode', width:100,align:"center", sortable:false},
			{name:'hospName',index:'goodsCode', width:140,align:"left", sortable:false},
	   		{name:'orgCode',index:'drugName', width:120,align:"center", sortable:false},
	   		{name:'contactName',index:'compName', width:120, sortable:false},
	   		{name:'contactTelephone',index:'areaName', width:120, sortable:false},
	   		{name:'status',index:'status', width:120, sortable:false,
	   			formatter:function(val){
	   				return val=='0'?"未确认":(val=='1'?"已确认":"其他");
	   			}	
	   		}
	   	],
		 rowNum: 20,
	     rowList: [10, 20,50,100],
	     rownumbers: true,
	     multiselect: true,
	     pager: "#prowed2",
	     viewrecords: true,
	     caption: "${compName}",
	     gridComplete:function(){
             autoRNWidth("gridList");
             selectByOneData("gridList");
         },
	     jsonReader: {
	         repeatitems: false,
	         id: "delRelId"
	     }
	   	
	});
})

function search(page){
	var hospCode = $.trim($("#hospCode").val());
	var hospName = $.trim($("#hospName").val());
	var status = $.trim($("#status").val());
	$("#gridList").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"hospCode":hospCode,
        		"hospName":hospName,
        		"status":status,
        },
        		page:(page || 1)
    }).trigger("reloadGrid"); //重新载入  
}
</script>
</body>
</html>